﻿using System.Diagnostics;
using System.Web.UI;
using AjaxControlToolkit;
[assembly: WebResource("Kevin.Controls.DetailsControl.DetailsControl.js", "text/javascript")]
[assembly: WebResource("Kevin.Controls.Dialog.css", "text/css", PerformSubstitution = true)]
namespace Kevin.Controls
{
    [ClientCssResource("Kevin.Controls.Dialog.css")]
    [RequiredScript(typeof(PopupControlExtender))]
    [ClientScriptResource("Kevin.Controls.DetailsControl", "Kevin.Controls.DetailsControl.DetailsControl.js")]
    public class DetailsControl:ScriptControlBase
    {
        public DetailsControl()
            : base(true, HtmlTextWriterTag.Div)
        { }

        #region Properties

        [ClientPropertyName("ServicePath")]
        public string ServicePath
        {
            get
            {
                return GetPropertyValue<string>("ServicePath", "");
            }
            set
            {
                SetPropertyValue<string>("ServicePath", value);
            }
        }
        [ClientPropertyName("DataListMethod")]
        public string DataListMethod
        {
            get
            {
                return GetPropertyValue<string>("DataListMethod", "");
            }
            set
            {
                SetPropertyValue<string>("DataListMethod", value);
            }
        }
        [ClientPropertyName("DetailMethod")]
        public string DetailMethod
        {
            get
            {
                return GetPropertyValue<string>("DetailMethod", "");
            }
            set
            {
                SetPropertyValue<string>("DetailMethod", value);
            }
        }

        [ClientPropertyName("DetailButton")]
        public string DetailButton
        {
            get
            {
                return GetPropertyValue<string>("DetailButton", "");
            }
            set
            {
                SetPropertyValue<string>("DetailButton", value);
            }
        }

        #endregion

        #region Help Methods

        [DebuggerStepThrough]
        protected V GetPropertyValue<V>(string propertyName, V nullValue)
        {
            if (ViewState[propertyName] == null)
            {
                return nullValue;
            }
            return (V)ViewState[propertyName];
        }

        [DebuggerStepThrough]
        protected void SetPropertyValue<V>(string propertyName, V value)
        {
            ViewState[propertyName] = value;
        }

        #endregion
    }
}
